﻿<UserControl x:Class="QLab.UserControls.SolutionExplorerView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:model="clr-namespace:QLab.Model"
             xmlns:util="clr-namespace:QLab.Utility"
             xmlns:uc="clr-namespace:QLab.UserControls"
             xmlns:converters="clr-namespace:QLab.Converters"
             mc:Ignorable="d" 
             d:DesignHeight="300" d:DesignWidth="300">
    <UserControl.Resources>
        <converters:BoolToVisibilityConverter x:Key="BoolToVisibilityConverter" FalseValue="Collapsed" TrueValue="Visible" />
    </UserControl.Resources>
    <UserControl.ContextMenu>
        <ContextMenu IsOpen="{Binding Path=ContextMenuOpened, Mode=TwoWay}">
            <MenuItem Header="Add" Visibility="{Binding Path=AddVisible, Converter={StaticResource ResourceKey=BoolToVisibilityConverter}}">
                <MenuItem Header="New Project..." Command="{Binding Path=NewProjectCommand}" Visibility="{Binding Path=NewProjectVisible, Converter={StaticResource ResourceKey=BoolToVisibilityConverter}}">
                    <MenuItem.Icon><Image Width="16" Height="16" Source="/QLab;component/Images/project_16.png" /></MenuItem.Icon>
                </MenuItem>
                <MenuItem Header="New Folder..." Command="{Binding Path=NewFolderCommand}" Visibility="{Binding Path=NewFolderVisible, Converter={StaticResource ResourceKey=BoolToVisibilityConverter}}">
                    <MenuItem.Icon>
                        <Image Width="16" Height="16" Source="/QLab;component/Images/folder_closed_16.png" />
                    </MenuItem.Icon>
                </MenuItem>
                <MenuItem Header="New File..." Command="{Binding Path=NewFileCommand}" Visibility="{Binding Path=NewFileVisible, Converter={StaticResource ResourceKey=BoolToVisibilityConverter}}">
                    <MenuItem.Icon>
                        <Image Width="16" Height="16" Source="/QLab;component/Images/file_ql_16.png" />
                    </MenuItem.Icon>
                </MenuItem>
            </MenuItem>
            <MenuItem Header="Remove" Command="{Binding Path=RemoveCommand}" Visibility="{Binding Path=RemoveVisible, Converter={StaticResource ResourceKey=BoolToVisibilityConverter}}"/>
            <MenuItem Header="Rename" Command="{Binding Path=RenameCommand}" Visibility="{Binding Path=RenameVisible, Converter={StaticResource ResourceKey=BoolToVisibilityConverter}}" IsEnabled="False" />
        </ContextMenu>
    </UserControl.ContextMenu>
    
    <DockPanel>
        <TreeView x:Name="navigationTree" ItemsSource="{Binding DataSource}">
            
            <TreeView.ItemTemplate>
                <HierarchicalDataTemplate ItemsSource="{Binding ChildItems}">
                    <StackPanel Orientation="Horizontal">
                        <Image Source="{Binding ImageSource}" Width="16" Height="16" Margin="0" />
                        <TextBlock Text="{Binding NodeText}" Margin="5 0 0 0" Padding="0" />
                    </StackPanel>
                </HierarchicalDataTemplate>
            </TreeView.ItemTemplate>
        </TreeView>
    </DockPanel>
</UserControl>
